package com.atf.atfconfigurator.utils;

import java.util.Iterator;
import java.util.List;

import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.HierarchicalConfiguration;
import org.apache.commons.configuration.XMLConfiguration;

public class WasConstant {
	
	private static XMLConfiguration wasConstantFile;
	public static String WAS_XML_JDBCPROVIDER_NAME="jdbcProviders";
	public static String WAS_XML_QCF_NAME="queueConenctionFactories";
	public static String WAS_XML_THREADPOOL_NAME="threadPool";
	public static String WAS_XML_JVM_NAME="jvmProperties";
	public static final String WAS_XML_DSCONNECTIONPOOL_NAME = "DSconnectionPool";
	public static final String WAS_XML_QCFCONNECTIONPOOL_NAME = "qcfConnectionPool";
    static{
    	try
    	{
    	     wasConstantFile = new XMLConfiguration(WasConstant.class.getResource("/com/atf/atfconfigurator/utils/WasConstant.xml"));
    	     System.out.println(wasConstantFile.toString());
    	    // do something with config
    	}
    	catch(ConfigurationException cex)
    	{
    		cex.printStackTrace();
    	}
    }
    
    public static String getPropertyValue(String key){
    	System.out.println(key);
        return wasConstantFile.getString(key, "");
    }
    
    public static List<Object> getList(String key){
    	return wasConstantFile.getList(key);
    }
    public static XMLConfiguration getWasConstantFile(){
    	return wasConstantFile;
    }
    
    public static void main(String args[]){
    	HierarchicalConfiguration sub = wasConstantFile.configurationAt("dataSources.DB2iseriesDS");
    	Iterator iterator=sub.getKeys();
    	while(iterator.hasNext()){
    		System.out.println(iterator.next());
    	}
    }
}
